MacOS – Make Safari load background tabs

macossafariweb-browsing

I think this is new behaviour since Safari 11, but I'm not absolutely certain.

I tend to leave Safari open all the time, with several pages of tabs, each for a different 'subject'.
On relaunch – if I've been cleaning less savoury cookies etc, or even that rare occasion I reboot – it used to reload all the tabs, whether currently visible or not.

This behaviour has changed & now each tab I go to will be blank & not load until I actually switch to it. I understand the philosophy might be to save resources until you 'prove' you actually need them, but honestly, if I didn't need them they wouldn't be open in the first place.
I've actually developed the habit of quickly flicking through all the tabs just after launch so I'm only seeing the irritating delay once.

Further irritation – the version it loads after the 2 second pause is still the cached version, so you have to immediately refresh it anyway:/

So I'd like to eliminate this behaviour.

I want, if possible, that each tab is already loaded with the current, not cached, version of the page at the time Safari was launched. I can handle my own refreshing after that, I just want to not have to wait that extra 2 seconds for each & every tab at first-use.

I have the Develop & Debug menus already visible, in case the 'fix' is in there, but frankly my comprehension of those menus is sub-optimal. I think in all honesty I have them visible to make me feel cool, rather than because I actually know what they're for 😉

This is currently Safari 11.0.2 on El Capitan.

Best Answer

I'm not aware of any way to alter Safari's default behavior, but this task can be automated easily enough if you have a means to run an AppleScript.

I use FastScripts and Keyboard Maestro myself, so I can assign global or app-specific keyboard shortcuts to my many scripts.

This AppleScript will reload every tab in Safari's front window.

----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2011/08/09 20:33
# dMod: 2015/11/14 16:46
# Appl: Safari
# Task: Reload Every Tab in front window.
# Libs: ELb
# Osax: None
# Tags: @Applescript, @Safari, @Reload, @Tabs, @Front, @Window
----------------------------------------------------------------

try

   tell application "Safari"

      set tabList to tabs of front window

      repeat with theTab in tabList
         tell theTab to do JavaScript "location.reload(true)"
      end repeat

   end tell

on error e number n
   stdErr(e, n, true, true) of me
end try

----------------------------------------------------------------
--» HANDLERS
----------------------------------------------------------------
on stdErr(e, n, beepFlag, ddFlag)
   set e to e & return & return & "Num: " & n
   if beepFlag = true then
      beep
   end if
   if ddFlag = true then
      if n ≠ -128 then
         try
            tell application (path to frontmost application as text) to set ddButton to button returned of ¬
               (display dialog e with title "ERROR!" buttons {"Copy Error Message", "Cancel", "OK"} ¬
                  default button "OK" giving up after 30)
            if ddButton = "Copy Error Message" then set the clipboard to e
         end try
      end if
   else
      return e
   end if
end stdErr
----------------------------------------------------------------

On my system I've given it a keyboard shortcut of ⌃⇧⌘R, which is a good mnemonic for me.

It's easy enough to alter the script to reload every tab in every window.

----------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2011/08/09 20:33
# dMod: 2011/08/09 20:57
# Appl: Safari
# Task: Reload Every Tab in Every Window.
# Libs: None
# Osax: None
# Tags: @Applescript, @Reload, @Tabs, @Every, @Window
----------------------------------------------------------------------------

tell application "Safari"

    set tabList to tabs of windows

    repeat with theWindow in tabList
        repeat with theTab in theWindow
            tell (theTab's contents)
                do JavaScript "location.reload(true)"
            end tell
        end repeat
    end repeat

end tell

----------------------------------------------------------------------------

I use this one so rarely I haven't given it a keyboard shortcut and have to manually activate it from the FastScripts menu. (This is also a safeguard to keep me from hitting a hotkey by accident and having to wait for every tab to reload.)

-ccs