Working with jQuery

Learn how to use external JavaScript libraries like jQuery with Transcrypt.

Introduction

So far, the only JavaScript functions we have used have been built-in. The next step we want to take is to utilize the functionality of external JavaScript libraries. JavaScript has a vast ecosystem of libraries available for doing web development. As previously mentioned, the philosophy behind Transcrypt is to take advantage of the existence of these libraries that already work in the web browser and use them rather than try and replace them with a Python equivalent. No sense in creating more work for ourselves, right?

There are several ways to accomplish this, the most straightforward being to import a JavaScript library from a hosted source right from our HTML file. This way, we can use the imported objects and call the library’s methods from any of our Python modules. This isn’t necessarily the best way since it gets added to the global namespace, but it will do for now until we add a few more steps to our workflow.

Get hands-on with 1200+ tech skills courses.