How to test a JS library on a browser console without any hassle?

Did you ever wish to test some JavaScript library but didn’t because it’s a lot of work to set up the library locally?

Well, recently I came across a trick and couldn’t believe that it has always been there. For most of the JavaScript libraries out there, if you visit their official documentation and open Console, you can use their library there without any masala.

Let me explain with an example of Jquery. If you ever wish to run Jquery on Console just go to jquery.com and open Console and boom. You have your free Jquery playground available to you.

Example 1

Let me illustrate it with another example, I will simply get the elements with the id menu-top using the Jquery syntax and magic, it works.

Example 2

This trick is available in a lot of other libraries like lodash, underscore, Ramda and even in ReactJS too further this might be there in your favorite library also. Let me know other cool libraries where we can do this.

Happy hacking!

, — Apr 9, 2022