Skip to content

Commit

Permalink
feat: don't load livereload in iframes and update minification
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Jul 4, 2023
1 parent 82957c0 commit 75e6699
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion RockFrontend.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ private function addLiveReloadScript()
{
// we only add live reloading to the frontend
if ($this->wire->page->template == 'admin') return;
$this->scripts('rockfrontend')->add($this->path . "livereload.min.js", "defer");
$file = $this->minifyFile($this->path . "livereload.js");
$this->scripts('rockfrontend')->add($file, "defer");
}

/**
Expand Down
3 changes: 3 additions & 0 deletions livereload.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ setTimeout(() => {
if (isModal) return;
let reloading = false;

// dont load in iframes
if (window.self !== window.top) return;

// timeout after file change was detected
// you can set this to 5000 if you see multiple redirects
// that means that something triggers another reload on reload
Expand Down
4 changes: 3 additions & 1 deletion livereload.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 75e6699

Please sign in to comment.