Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use yepnope

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how to use yepnope, I hope you will get something after reading this article. Let's discuss it together.

Yepnope.js is an ultra-fast conditional asynchronous resource loader that allows you to load only the resources you use (css and js).

A typical example of yepnope.js:

Yepnope ({

Test:Modernizr.geolocation

Yep:'normal.js'

Nope: ['polyfill.js','wrapper.js']

})

This example indicates that normal.js is loaded if Modernizr.geolocation is true, polyfill.js and wrapper.js are loaded if false.

Yepnope complete syntax:

Yepnope ([{]

Test:/*boolean (ish) input condition * /

Yep:/*array (ofstrings) | Resources loaded when the string- condition is true * /

Nope:/*array (ofstrings) | Resources loaded when the string- condition is false * /

Both:/*array (ofstrings) | string- condition is loaded regardless of whether it is true or false * /

Load:/*array (ofstrings) | string- condition is loaded regardless of whether it is true or false * /

Callback:/*function (testResult,key) | object {key:fn} callback function * /

Function executed after complete:/*function loading is completed * /

},.])

Why use yepnope:

Only 1.6K after Gzip is smaller than most resource loaders.

Can load CSS and JS

Yepnope has passed the tests of all the browsers the author can find.

Yepnope completely separates resource loading and execution, so that you can control the order in which resources are executed

Provide a logical combination of friendly API and facilitation resources

Modular design, you can expand your own functions (see Prefixes and filters later)

Encourage loading resources on demand

Integrated into Modernizr

By default, it is always executed in the order of the resource list (the list of files you provide).

Can handle resource fallback (fallback), and still give priority to parallel download dependent scripts, take a look at the code is easier to understand.

After reading this article, I believe you have a certain understanding of "how to use yepnope". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report