I'm working on optimizing my site, and one of the things Google PageSpeed is suggesting is to "defer parsing of JavaScript". I tried deferring all of my javascript files, but that breaks some functionality. I need some to load before and some after. Is there a way to determine this programmatically?
Asked
Active
Viewed 101 times
1
-
I am not sure what you are looking for. Something like require.js? – ubik Apr 24 '13 at 19:58
-
You want to parse the file's contents? Anything is possible with enough time. I doubt it would be cost effective though. – BNL Apr 24 '13 at 19:58
-
Anyway, have you heard about HTML5's `async` and `defer` attributes? – ubik Apr 24 '13 at 19:59
-
I don't think you can programmatically determine whether a functionality needs to be loaded in `head` or can be fetched asynchronously. Don't you know that yourself? – Bergi Apr 24 '13 at 20:03
-
What you are looking for is Javascript dependency management. I would say its not possible. More details are discussed here - http://stackoverflow.com/questions/3202606/javascript-dependency-management – hop Apr 24 '13 at 20:24