Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*== Preload External Scripts ==*/
- add_action('wp_head', function () {
- // Define your script URLs
- $scripts = [
- "https://sw-assets.ekomiapps.de/static_resources/slick.js",
- "https://maps.googleapis.com/maps-api-v3/api/js/61/6d/controls.js",
- "https://maps.googleapis.com/maps-api-v3/api/js/61/6d/places_impl.js",
- "https://widget.intercom.io/widget/livuebsx",
- "https://js.intercomcdn.com/frame-modern.a96890ff.js",
- "https://js.intercomcdn.com/vendor-modern.2adcf83e.js"
- ];
- // Output <link rel="preload"> tags
- foreach ($scripts as $src) {
- echo '<link rel="preload" as="script" href="' . esc_url($src) . '">' . "\n";
- }
- // Output <script> tags with async/defer based on type
- ?>
- <script>
- (function() {
- const scripts = [
- { src: "https://sw-assets.ekomiapps.de/static_resources/slick.js", async: false },
- { src: "https://maps.googleapis.com/maps-api-v3/api/js/61/6d/controls.js", async: false },
- { src: "https://maps.googleapis.com/maps-api-v3/api/js/61/6d/places_impl.js", async: false },
- { src: "https://widget.intercom.io/widget/livuebsx", async: true },
- { src: "https://js.intercomcdn.com/frame-modern.a96890ff.js", async: false },
- { src: "https://js.intercomcdn.com/vendor-modern.2adcf83e.js", async: false }
- ];
- scripts.forEach(({ src, async }) => {
- const script = document.createElement("script");
- script.src = src;
- script.async = async;
- script.defer = !async;
- document.head.appendChild(script);
- });
- })();
- </script>
- <?php
- }, 1); // Priority 1
- /*== END - Preload External Scripts ==*/
- /*== Prefetch Transport.io Quote Form from its system ==*/
- add_action('wp_head', function () {
- echo '<link rel="dns-prefetch" href="//booking.buscharter.com.au">' . "\n";
- echo '<link rel="preconnect" href="https://booking.buscharter.com.au" crossorigin>' . "\n";
- }, 1);
- /*== END - Prefetch Transport.io Quote Form from its system ==*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement