Skip to content

Commit

Permalink
lazy load of injected code
Browse files Browse the repository at this point in the history
  • Loading branch information
ritwickdey committed Jan 19, 2022
1 parent 1b8f82c commit 5f09765
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/live-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ var fs = require('fs'),
require('colors');


var INJECTED_CODE = fs.readFileSync(path.join(__dirname, "injected.html"), "utf8");


let useBrowserExtension = false;
let GET_INJECTED_CODE = () => {
return useBrowserExtension === true ? '' : INJECTED_CODE;
if (!GET_INJECTED_CODE.cache){
GET_INJECTED_CODE.cache = fs.readFileSync(path.join(__dirname, "injected.html"), "utf8");
}

return useBrowserExtension === true ? '' : GET_INJECTED_CODE.cache;
}

var LiveServer = {
Expand Down

0 comments on commit 5f09765

Please sign in to comment.