{"id":15652261,"date":"2022-05-17T09:20:40","date_gmt":"2022-05-17T09:20:40","guid":{"rendered":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/wordpress.org\/support\/topic\/dont-combine-javascript-by-default\/"},"modified":"2022-05-17T09:21:54","modified_gmt":"2022-05-17T09:21:54","slug":"dont-combine-javascript-by-default","status":"publish","type":"topic","link":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/wordpress.org\/support\/topic\/dont-combine-javascript-by-default\/","title":{"rendered":"Don&#8217;t combine JavaScript type=module by default?"},"content":{"rendered":"<p>On a website we are currently getting the following error:<\/p>\n<p><code>Uncaught SyntaxError: Cannot use import statement outside a module (at siteground-optimizer-combined-js-4c066a5266b58bf7cc9930ae49d96fe4.js:122:508)<\/code><\/p>\n<p>This is because a plugin enqueues a module script and changes the script tag via the <code>script_loader_tag<\/code> filter to <code>&lt;script type=&quot;module&quot; src=&quot;...&quot;&gt;&lt;\/script&gt;<\/code>.<\/p>\n<p>https:\/\/round-lake.dustinice.workers.dev:443\/https\/developer.mozilla.org\/en-US\/docs\/Web\/HTML\/Element\/script#attr-type<\/p>\n<p>We were wondering if it might be wise for the SiteGround Optimizer to exclude scripts with <code>type=&quot;module&quot;<\/code> from combining JavaScript by default?<\/p>\n<p>Or are there situations where <code>&lt;script type=&quot;module&quot; src=&quot;...&quot;&gt;&lt;\/script&gt;<\/code> can be successfully combined? (I&#8217;m not a JavaScript expert).<\/p>\n","protected":false},"template":"","class_list":["post-15652261","topic","type-topic","status-publish","hentry","topic-tag-import","topic-tag-javascript","topic-tag-module","topic-tag-syntaxerror"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/15652261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":2,"href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/15652261\/revisions"}],"predecessor-version":[{"id":15652266,"href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/15652261\/revisions\/15652266"}],"wp:attachment":[{"href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=15652261"}],"curies":[{"name":"wp","href":"https:\/\/round-lake.dustinice.workers.dev:443\/https\/api.w.org\/{rel}","templated":true}]}}