I am having aspx which has jquery. Due to delay in loading jquery I am facing some style issues. Please can anyone tell me how to load jquery very fast.
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
LABjs is a script loader that allows you to load scripts in a dependancy order, so you can start by loading jQuery and not block other scripts from loading. You would only block those scripts that are jQuery dependant. This may help you increase the page load speed.
I read a Blog post by Sam Saffron from Stackoverflow on this topic today. I didnt try out the authors tipps yet though so I cant confirm.
http://samsaffron.com/archive/2012/02/17/stop-paying-your-jquery-tax
the tl;dr; is to push jquery to the footer of the page and define a $.ready function in the header which captures all the scripts that couldnt yet be run because jquery didnt load until the actual $.ready function is loaded.
Make sure that jQuery file is delivered with content expiry headers set, so it can be cached by the browser.
Put your script after all of your CSS files(). And you can load it like so:
First of all it will load your jQuery from the Google CDN, which is one of the fastest around. Secondly it is async across browsers and will not block anything else loading on your page.