{"action":"created","issue":{"url":"https://api.github.com/repos/less/less.js/issues/2521","labels_url":"https://api.github.com/repos/less/less.js/issues/2521/labels{/name}","comments_url":"https://api.github.com/repos/less/less.js/issues/2521/comments","events_url":"https://api.github.com/repos/less/less.js/issues/2521/events","html_url":"https://github.com/less/less.js/issues/2521","id":63599886,"number":2521,"title":"Consider a different browser embed method","user":{"login":"matthew-dean","id":414752,"avatar_url":"https://avatars.githubusercontent.com/u/414752?v=3","gravatar_id":"","url":"https://api.github.com/users/matthew-dean","html_url":"https://github.com/matthew-dean","followers_url":"https://api.github.com/users/matthew-dean/followers","following_url":"https://api.github.com/users/matthew-dean/following{/other_user}","gists_url":"https://api.github.com/users/matthew-dean/gists{/gist_id}","starred_url":"https://api.github.com/users/matthew-dean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthew-dean/subscriptions","organizations_url":"https://api.github.com/users/matthew-dean/orgs","repos_url":"https://api.github.com/users/matthew-dean/repos","events_url":"https://api.github.com/users/matthew-dean/events{/privacy}","received_events_url":"https://api.github.com/users/matthew-dean/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-03-23T01:40:45Z","updated_at":"2015-03-24T16:05:28Z","closed_at":null,"body":"One of the things that's been around for a long time has been this way to attach Less stylesheets in-browser.\r\n```\r\n<link rel=\"stylesheet/less\" type=\"text/css\" href=\"styles.less\" />\r\n```\r\nWhen I was doing some performance testing recently, I noticed two events which are created unnecessarily by this method. The first is obvious. It downloads styles.less but doesn't do anything with it, so there are two initial \"requests\" for styles.less, but theoretically, the second should be loaded from cache. (Hopefully?)\r\n\r\nThe second made me say, \"Hmm.\" By telling the browser that this is a stylesheet, we're telling the browser to go ahead and try to parse it and pull out any relevant styles. Sure enough, Chrome showed an event of parsing the stylesheet, which is not really what we want. I assume we never see those styles because it never actually applies them based on the ```rel``` attribute, but it does parse them.\r\n\r\nNow, I don't know how much of a performance hit these two things might be. BUT, considering that there are lots of other ways to indicate to less.js what the stylesheet is, then it seems like an unnecessary burden.\r\n\r\nIt's possible that even eliminating ```type=\"text/css\"``` may do it, or there may be other link types that don't have the browser request (or parse) the resource."},"comment":{"url":"https://api.github.com/repos/less/less.js/issues/comments/85579567","html_url":"https://github.com/less/less.js/issues/2521#issuecomment-85579567","issue_url":"https://api.github.com/repos/less/less.js/issues/2521","id":85579567,"user":{"login":"matthew-dean","id":414752,"avatar_url":"https://avatars.githubusercontent.com/u/414752?v=3","gravatar_id":"","url":"https://api.github.com/users/matthew-dean","html_url":"https://github.com/matthew-dean","followers_url":"https://api.github.com/users/matthew-dean/followers","following_url":"https://api.github.com/users/matthew-dean/following{/other_user}","gists_url":"https://api.github.com/users/matthew-dean/gists{/gist_id}","starred_url":"https://api.github.com/users/matthew-dean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthew-dean/subscriptions","organizations_url":"https://api.github.com/users/matthew-dean/orgs","repos_url":"https://api.github.com/users/matthew-dean/repos","events_url":"https://api.github.com/users/matthew-dean/events{/privacy}","received_events_url":"https://api.github.com/users/matthew-dean/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T16:05:28Z","updated_at":"2015-03-24T16:05:28Z","body":"> Firefox Chrome and recent IE browsers implement it, but browsers schedule its priority differently. Iirc it's scheduled quite low on Firefox even. \r\n\r\nThat's right. Prefetch is basically \"grab this resource when it's convenient\". Usually that happens right after or around the onload event. So that's not what we want. \"subresource\" WOULD probably give us what we want (although still a lower priority than text/css), but I think is only supported by Chrome.\r\n\r\n> Honestly, I feel this entire exercise of streamlining the file-load performance for the in-browser Less compiler is purely academical anyway. If you want increased page-load speed, you should precompile the Less files to plain old CSS files and serve those.\r\n\r\nI essentially agree. I just wanted to open up the question and see if there was a quick switch to something that wouldn't trigger a parse but still maintain priority. Couldn't you just pass the root file into Less options? Then it wouldn't have to query the DOM, and it just retrieves it right away anyway. And the browser wouldn't try to parse it. Seems the most direct / efficient of all the options."}}