File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -322,6 +322,20 @@ <h1>service-injector Demo</h1>
322322 injectorStyleElement = null ;
323323 }
324324
325+ // Determine script URL based on environment (local vs deployed)
326+ function getScriptUrl ( ) {
327+ var isLocal = window . location . hostname === 'localhost' ||
328+ window . location . hostname === '127.0.0.1' ||
329+ window . location . protocol === 'file:' ;
330+
331+ if ( isLocal ) {
332+ return '../dist/index.iife.js' ;
333+ } else {
334+ // Use CDN for deployed demo
335+ return 'https://unpkg.com/service-injector/dist/index.iife.js' ;
336+ }
337+ }
338+
325339 // Load injector with current configuration
326340 function loadInjector ( ) {
327341 // Clean up any existing injector
@@ -352,7 +366,7 @@ <h1>service-injector Demo</h1>
352366 // Create and inject new script
353367 var script = document . createElement ( 'script' ) ;
354368 script . id = 'service-injector' ;
355- script . src = '../dist/index.iife.js' + queryString ;
369+ script . src = getScriptUrl ( ) + queryString ;
356370
357371 // Track the style element that will be added
358372 var styleCount = document . querySelectorAll ( 'style' ) . length ;
You can’t perform that action at this time.
0 commit comments