File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 11{% extends "base.html" %}
22{% block extra_head %}
3- < script src ="https://unpkg.com/maplibre-gl@1.15.2/dist/maplibre-gl.js "> </ script >
43< link href ="https://unpkg.com/maplibre-gl@1.15.2/dist/maplibre-gl.css " rel ="stylesheet " />
54
65< style >
177176</ div >
178177
179178< script >
180- maplibregl . accessToken = "pk.eyJ1IjoidHJpc2NodGFuZGVyIiwiYSI6ImNsNmZwNXY2MDAxOWEzZG41b213NWJ2ZjIifQ.pMjBga8kA5XQuDw19WQ8TQ" ;
179+ // Load MapLibre GL dynamically to prevent render blocking
180+ function loadMapLibrary ( ) {
181+ const script = document . createElement ( 'script' ) ;
182+ script . src = 'https://unpkg.com/maplibre-gl@1.15.2/dist/maplibre-gl.js' ;
183+ script . onload = initializeMap ;
184+ document . head . appendChild ( script ) ;
185+ }
186+
187+ function initializeMap ( ) {
188+ maplibregl . accessToken = "pk.eyJ1IjoidHJpc2NodGFuZGVyIiwiYSI6ImNsNmZwNXY2MDAxOWEzZG41b213NWJ2ZjIifQ.pMjBga8kA5XQuDw19WQ8TQ" ;
181189
182190var map = new maplibregl . Map ( {
183191 container : "map" ,
@@ -433,5 +441,14 @@ <h3 class="name-popup">${properties.name}</h3>
433441 preload ( ...{ { thumbnails } } ) ;
434442}
435443
444+ }
445+
446+ // Load map library after page loads to prevent blocking
447+ if ( document . readyState === 'loading' ) {
448+ document . addEventListener ( 'DOMContentLoaded' , loadMapLibrary ) ;
449+ } else {
450+ loadMapLibrary ( ) ;
451+ }
452+
436453</ script >
437454{% endblock %}
You can’t perform that action at this time.
0 commit comments