• Resolved paulswarthout

    (@paulswarthout)


    Hi,

    I wanted to let you know about a change that I made to your code as it is running on my website. I did it to solve an annoying problem. I created a new block using Block-Lab. I created the <child-theme>/blocks/<new-block>.css file but I didn’t like how the block displayed. But every time I made a change to the css file, I had to go to the browser’s settings and clear the image/file cache before Chrome would let go of the cached copy of the .css file.

    I found in your code, line 450 in the 1.5.2 version (line 453 in 1.5.3) of php/blocks/class-loader.php and changed it from:
    wp_get_theme()->get( ‘Version’ )
    to
    (defined(‘SCRIPT_DEBUG’) && SCRIPT_DEBUG ? time() : wp_get_theme()->get( ‘Version’ ))

    I used ‘SCRIPT_DEBUG’ because that’s what you used when loading the plugin’s classes during debugging.

    Now, I can change my <new-block>.css file at will and immediately see the changes with a browser refresh. I am bringing this to your attention in the hopes that you might do something similar in a future release such that we can develop our new blocks more efficiently, and that I don’t have to remember to go change it again, with each new Block-Lab release. ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Ryan Kienstra

    (@ryankienstra)

    Hi @paulswarthout,
    Thanks a lot for letting us know about that line of code. I’ll look at how we might do something like that.

    Plugin Author Ryan Kienstra

    (@ryankienstra)

    That’s a good suggestion.

    For now, have you used the Chrome preference ‘Disable cache (while DevTools is open)’?

    For the time being, that should prevent the need for the modified code you mentioned, as long as you open the DevTools after making an edit to the CSS file:

    https://cldup.com/45IvVKdPAF.png

    Maybe that’s what you meant by ‘go to the browser’s settings and clear the image/file cache.’

    Thanks a lot for using Block Lab, and have a great weekend.

    Thread Starter paulswarthout

    (@paulswarthout)

    Hi @ryankienstra ,

    I have used the DevTools preference ‘Disable cache’. That does work much of the time. Unfortunately, sometimes Chrome seems to ignore that setting. I’ll be debugging code and the page will start acting weird. If I clear the files/cache, everything will start working correctly again.

    By clear the image/file cache, I meant — chrome://settings/clearBrowserData. Set the time range to All Time, and on the Basic tab, check the box Cached images and files. Then tap the Clear button.

    For now, I thought I’d write a simple plugin to modify that line of code should it ever change. Shouldn’t be too hard. ??

    You have a great weekend as well.

    Plugin Author Ryan Kienstra

    (@ryankienstra)

    Hi @paulswarthout,
    Thanks, that does sound like a hassle to manually change that setting to see your changes appear.

    I’ll think about adding that SCRIPT_DEBUG check that you mentioned, that sounds reasonable.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘A Code Modification’ is closed to new replies.