All Projects → CapMousse → Include.js

CapMousse / Include.js

Licence: mit
A tiny but heavy on-demand async javascript/css loader

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Include.js

Requirejs Demo
《RequreJS学习笔记》
Stars: ✭ 164 (+12.33%)
Mutual labels:  requirejs, module
Angular Async Loader
Load modules and components asynchronously for angular 1.x application.
Stars: ✭ 137 (-6.16%)
Mutual labels:  requirejs, loader
vscode-requirejs
Provides goto definition functionality for require js modules.
Stars: ✭ 20 (-86.3%)
Mutual labels:  module, requirejs
Node Hot Loader
Hot module replacement (hot reload) for Node.js applications. Develop without server restarting.
Stars: ✭ 111 (-23.97%)
Mutual labels:  module, loader
Terraform Aws Airship Ecs Service
Terraform module which creates an ECS Service, IAM roles, Scaling, ALB listener rules.. Fargate & AWSVPC compatible
Stars: ✭ 139 (-4.79%)
Mutual labels:  module
Robojs
RoboJS is a library that aims to dynamically load JS modules depending on how the DOM is composed.
Stars: ✭ 133 (-8.9%)
Mutual labels:  loader
Androidmodulesamples
🎨基于 MVP + RxJava + Retrofit + EventBus + Arouter 的 Android 组件化开发框架实践
Stars: ✭ 129 (-11.64%)
Mutual labels:  module
React Native Wormhole
⚛️ 🌌 Inter-dimensional Portals for React Native. 👽 🖖
Stars: ✭ 133 (-8.9%)
Mutual labels:  loader
Web Vitals Module
Web Vitals: Essential module for a healthy Nuxt.js
Stars: ✭ 138 (-5.48%)
Mutual labels:  module
Vue Loaders
Vue + loaders.css
Stars: ✭ 127 (-13.01%)
Mutual labels:  loader
Godotads
Godot all in one ads module for Android. (Customizable)
Stars: ✭ 137 (-6.16%)
Mutual labels:  module
Maclaunch
Manage your macOS startup items.
Stars: ✭ 133 (-8.9%)
Mutual labels:  loader
Omil
📝Webpack loader for Omi.js React.js and Rax.js components 基于 Omi.js,React.js 和 Rax.js 单文件组件的webpack模块加载器
Stars: ✭ 140 (-4.11%)
Mutual labels:  loader
Cohesion
A tool for measuring Python class cohesion.
Stars: ✭ 129 (-11.64%)
Mutual labels:  module
Require Vuejs
RequireJS plugin to async and dynamic load and parse .vue components
Stars: ✭ 143 (-2.05%)
Mutual labels:  requirejs
Jtmaterialspinner
An iOS material design spinner view
Stars: ✭ 127 (-13.01%)
Mutual labels:  loader
Quill Cursors
A multi cursor module for Quill text editor.
Stars: ✭ 139 (-4.79%)
Mutual labels:  module
Ng Block Ui
Block UI Loader/Spinner for Angular
Stars: ✭ 135 (-7.53%)
Mutual labels:  loader
React Content Loader
⚪ SVG-Powered component to easily create skeleton loadings.
Stars: ✭ 11,830 (+8002.74%)
Mutual labels:  loader
React Spinners
A collection of loading spinner components for react
Stars: ✭ 2,054 (+1306.85%)
Mutual labels:  loader

Include.js Build Status

Include.js is a tiny (1,3ko minified and gziped) Javascript loader. It can load normal javascript files or css but is more efficient with web modules.

When it's possible, it will use async loading to speed up you page and will ensure the good executions of your script. It support nested dependencies, a useful feature to create clean and flexible javascript application.

Include.js was tested on :

  • Chrome √
  • Firefox √
  • Opera √
  • Safari √
  • IE (> 6) √

Define modules

In the old javascript days, to create a module, you would add a simple wrapper on your code, like a auto-called anonymous functiom.

(function(env){
  //your code here
})(window);

Now, to define a module meeting the [AMD standard](http://requirejs.org/docs/whyamd.), just use include() as the wrapper of your code.

With AMD definition, you can create module having dependencies realy easily, executing code only when the dependencies are available.

//define a new module with include
include(['dep1', 'dep2'], function (dep1, dep2) {

  //define the module value with return
  return dep2({
    name: dep1('Mars Curiosity')
  });
});

Named modules

Modules without a name are automatically named with their file name. This is what makes modules very portable and easily usable in others projetcs.

Naming module manually must be avoided to prevent conflicts or loading missing module. Only use module naming in controlled cases or for better performances.

//define a named module with dependencies
include('name', ['dep1', 'dep2'], function (dep1, dep2) {
  return dep2({
    name: dep1('Mars Curiosity')
  });
});

External dependencies

You can also load external dependencies, useful to speed up website loading time and prevent parsing to be blocked.

External dependencies can be AMD module or normal javascripts. If no module is found, argument send to the callback will be the index of the script in the dependencies array instead of the module function.

include(['//website/jquery.js', '//website/amd-module.js'], function (indexOfJquery, amdModule) {
  $('#block').text(amdModule());
});

Load CSS

You can also load css like any other module. The callback will be called when the browser will have parsed the style.

include(['/styles/alternative.css', '//website/external-css.js'], function (css1, css2) {
  //css1 and css2 will be null
});

Already using a script loader ?

If you already use a script loader you can replace it with Include.js without problemes and without rewriting code. define() and require() are supported by Include.js. Let's be light !

Developed by

License

See LICENSE file

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].