• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Daniel Pringle

Web Design

  • About
  • Portfolio
  • Code
  • Blog
  • Contact
Home › Code › Using modular JavaScript with WordPress

Using modular JavaScript with WordPress

August 4, 2021 by Dan

When working with JS modules we need to include type="module" in the <script> element in order to declare the script as a module, for example:

<script type="module" src="theme-script.js"></script>

With WordPress when we enqueue scripts we don’t have the option to add type=”module” but we can use the script_loader_tag to filter the enqueued scripts as in the example gist below:

Filed under: WordPress

Primary Sidebar

Working with businesses to develop their online identity building scale-able web solutions that work for you, your team and your customers.

  • * Web Design & Development *
  • * SEO *
  • * Content Marketing *

Recent Posts

  • What is web design?
  • How to Move from http to https with WordPress
  • Is your website GDPR compliant?
  • Why your business needs a website

Footer

Quick Links

  • About
  • Portfolio
  • Web Design & Development
  • SEO
  • Digital Marketing
  • Code

say hello

  • Facebook
  • GitHub
  • LinkedIn
  • Pinterest
  • Twitter

Recent Posts

  • What is web design?
  • How to Move from http to https with WordPress
  • Is your website GDPR compliant?
  • Why your business needs a website

© Copyright 2016 - 2022 danielpringle.co.uk · All Rights Reserved ·