![]() jsdelivr Also an open source project this one can take the files from NPMĮach of these CDNs will allow you to load the latest JQuery.Microsoft Ajax Content Delivery Network Like Google this is also only a small selection of files but uses Microsoft servers.Google Libraries A much smaller selection but with all the power of Google.CDNJS is an open source project to provide JavaScript files.You can load libraries such as JQuery from fast and free CDN's. The last thing that I want to teach you about is loading JavaScript from a CDN. One example of this is when you need to load a framework like JQuery. We have loaded scripts from the local webserver but what if the file is on another server. With the defer attribute you know the page will not block and the script will download in the background. This is how you would add the async attribute: As soon as the file has downloaded the browser will run the code. This allows the page to continue loading. ![]() The async attribute tells the browser to download the file in the background. Once the code has finished running the page will resume loading.Īsync and defer will improve web performance by allowing the page to continue to load. Once the file is ready the browser runs the code. ![]() When the browser finds a script tag in the HTML the page loading stops while the browser fetches the script. Now that we have an external script we can look at some of the other script attributes. When the browser reads that line it will fetch the JavaScript file and run it. ![]() The HTML will load the script when it loads the page as it did before. All we need is the src attribute which is the path to the file. Remember, we don't need to include the type because the file is JavaScript. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |