I am looking at using less . js (looks great), but our site requires some styles to load dynamically after the page loads. It seems, however, that all LESS style sheets should be loaded before the less.js script is loaded. those. it works
<link rel="stylesheet/less" href="/static/less/style.less"/> <script src="http://lesscss.googlecode.com/files/less-1.0.30.min.js"></script>
but it fails if the lines are exchanged, neither firefox nor chrome try to load "style.less" if they are not ordered correctly. The ordering requirement is explicitly stated in this tutorial .
Is there a way to load fewer style sheets after loading the start page?
Please note that this blog describes the watch function -
which will automatically update CSS whenever you save the LESS code
therefore, it seems reasonable to expect that after loading the page I can add some LESS rules. Looks like I missed something.
Greetings
Colin
UPDATE: the code used to verify the behavior described in the comments (less the stylesheet specified after the script) -
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Simple</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script src="/static/js/less-1.0.31.min.js"></script> <link rel="stylesheet/less" href="/static/less/style.less" id="abc123"/> </head> <body> <div id="container"> <div>Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.</div> </div> <div id="#abc">Bingo</div> </body> <script> console.log("refreshing styles..."); less.sheets.push(document.getElementById('abc123')); //var lessStyle = $("<style>#abc { color: blue; }</style>").attr("id", "less:static-less-style").attr("type", 'text/less'); //$("head").append(lessStyle); less.refresh(true); console.log("refreshed..."); </script> </html>
and less styles
@primary_color: green; .rounded(@radius: 5px) { -moz-border-radius: @radius; -webkit-border-radius: @radius; border-radius: @radius; }
javascript css less
hawkett Jul 04 '10 at 14:45 2010-07-04 14:45
source share