Best way import jQuery plugins or external client scripts?
See original GitHub issueMy projects comes with quite many external jQuery plugins. And I got troubles to import them into a specific component and make them work with development mode by npm start
(server side rendering).
My current solutions is to add them all to the bottom of Html.js
return func. But, this way increases page load.
Issue Analytics
- State:
- Created 7 years ago
- Comments:21 (2 by maintainers)
Top Results From Across the Web
What's The Best Way To Include jQuery In A Rails App?
Copy external JavaScript libraries, like the jQuery plugins to the vendor/assets/javascripts folder. Allow the asset pipeline of Rails to combine all of it ......
Read more >How To Properly Add jQuery Scripts To WordPress (Easy Steps)
1.Enter jQuery Stealth Mode The first way to get around compatibility mode is to get stealthy with your code. For example, if you're...
Read more >Day 09: Using jQuery Plugin Inside the Client-Side Web Part ...
In this SharePoint Developer Framework video we walk-through the process of including a the accordion jQuery plugin within the client -side ...
Read more >Building SharePoint Framework Web Parts using jQuery ...
The way loading external scripts should work In order to use jQuery in your Web Part, you would add: import * as jQuery...
Read more >Use jQuery plugin from asynchronously loaded external script
I understand why - the plugin is being called before the script is loaded. I know a quick and dirty hack is just...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@minhnguyenwp : please stop importing jQuery into your component, that will increase the time on bundling process of Webpack and the size of
bundle.js
/vendor.js
file as well. Just add a<script />
tag which hassrc
attribute link to your jquery file and use$
in every components’componentDidMount
functions without re-importing jQuery.Be aware of eslint alert that
'$' is not defined
, put a comment/* global $ */
on top of your files or update.eslintrc.js
file atglobals
property to ignore this alert.Anyway, using jQuery to handle the DOM might cause React DOM tree crash (React indexes all the actual rendered DOMs by it virtual DOM tree). So, please ensure you read these posts before getting your hands dirty with React and jQuery co-operation.
Create one component jQuery, example (components/Jquery.js:
In your component you will use a jQuery plugin, example (components/Slider.js):