All Projects → blueberryapps → React Load Script

blueberryapps / React Load Script

Licence: mit
React component that makes it easy to load 3rd party scripts

Programming Languages

javascript
184084 projects - #8 most used programming language
script
160 projects

Projects that are alternatives of or similar to React Load Script

assetter
Assets manager for PHP. Allow manage CSS and JS files in website and its dependencies. Also allows refresh cache in browsers by adding revisions of loaded files. Builtin plugins to compile SASS and/or LESS styles to CSS just-in-time.
Stars: ✭ 14 (-95.97%)
Mutual labels:  loader
typedb-loader
TypeDB Loader - Data Migration Tool for TypeDB
Stars: ✭ 43 (-87.61%)
Mutual labels:  loader
Lodjs
JavaScript模块加载器,基于AMD。迄今为止,对AMD理解最好的实现。
Stars: ✭ 296 (-14.7%)
Mutual labels:  loader
postcss-font-grabber
A postcss plugin, it grabs remote font files and update your CSS, just like that.
Stars: ✭ 26 (-92.51%)
Mutual labels:  loader
snowplow-bigquery-loader
Loads Snowplow enriched events into Google BigQuery
Stars: ✭ 15 (-95.68%)
Mutual labels:  loader
React Image Appear
ReactJS component to make images appear with transition as they load.
Stars: ✭ 264 (-23.92%)
Mutual labels:  loader
Loaders
Process dialogs, loading bars, etc.
Stars: ✭ 23 (-93.37%)
Mutual labels:  loader
Ng Http Loader
🍡 Smart angular HTTP interceptor - Intercepts automagically HTTP requests and shows a spinkit spinner / loader / progress bar
Stars: ✭ 327 (-5.76%)
Mutual labels:  loader
ngx-smart-loader
Smart loader handler to manage loaders everywhere in Angular apps.
Stars: ✭ 28 (-91.93%)
Mutual labels:  loader
Rsup Progress
❤️ A simple progress bar with promises support
Stars: ✭ 290 (-16.43%)
Mutual labels:  loader
typed-css-modules-loader
💠 Webpack loader for typed-css-modules auto-creation
Stars: ✭ 62 (-82.13%)
Mutual labels:  loader
config
Simple configuration management for PHP
Stars: ✭ 15 (-95.68%)
Mutual labels:  loader
Lumie
✨ An opinionated way to keep your express API organized
Stars: ✭ 277 (-20.17%)
Mutual labels:  loader
ng-loader
Webpack loader for AngularJs components
Stars: ✭ 28 (-91.93%)
Mutual labels:  loader
Loading Bar
Flexible, light weighted and super fast Progress Bar Library
Stars: ✭ 300 (-13.54%)
Mutual labels:  loader
react-awesome-loaders
🚀 High quality, super responsive and completely customisable Loading Animations to insert into your website with single line of code.
Stars: ✭ 146 (-57.93%)
Mutual labels:  loader
Vue Spinners
💫 A collection of loading spinner components for Vuejs
Stars: ✭ 255 (-26.51%)
Mutual labels:  loader
Markdown Loader
markdown loader for webpack
Stars: ✭ 335 (-3.46%)
Mutual labels:  loader
Waitme
jquery plugin for easy creating loading css3/images animations
Stars: ✭ 302 (-12.97%)
Mutual labels:  loader
Ngx Skeleton Loader
Make beautiful, animated loading skeletons that automatically adapt to your Angular apps
Stars: ✭ 278 (-19.88%)
Mutual labels:  loader

react-load-script CircleCI Dependency Status

This package simplifies loading of 3rd party scripts in your React applications.

Motivation

There are situations when you need to use a 3rd party JS library in your React application (jQuery, D3.js for rendering charts, etc.) but you don't need it everywhere and/or you want to use it only in a response to users actions. In cases like this, preloading the whole library when application starts is an unnecessary and expensive operation which could possibly slow down your application.

Using the Script component this package provides you with, you can easily load any 3rd party scripts your applications needs directly in a relevant component and show a placeholder while the script is loading (e.g. a loading animation). As soon as the script is fully loaded, a callback function you'll have passed to Script is called (see example below).

Supported React versions

This package requires React 0.14.9 and higher.

API

The package exports a single component with the following props:

onCreate

Called as soon as the script tag is created.

onError (required)

Called in case of an error with the script.

onLoad (required)

Called when the requested script is fully loaded.

url (required)

URL pointing to the script you want to load.

attributes

An object used to define custom attributes to be set on the script element. For example, attributes={{ id: 'someId', 'data-custom: 'value' }} will result in <script id="someId" data-custom="value" />

Example

You can use the following code to load jQuery in your app:

import Script from 'react-load-script'

...

render() {
  return (
    <Script
      url="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"
      onCreate={this.handleScriptCreate.bind(this)}
      onError={this.handleScriptError.bind(this)}
      onLoad={this.handleScriptLoad.bind(this)}
    />
  )
}

...

handleScriptCreate() {
  this.setState({ scriptLoaded: false })
}

handleScriptError() {
  this.setState({ scriptError: true })
}

handleScriptLoad() {
  this.setState({ scriptLoaded: true })
}

License

MIT 2016

Made with love by

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].