Skip to content

Conversation

SGudbrandsson
Copy link
Contributor

Changed the 'text widget' lazy loading to 'sidebar widgets' lazy loading.
Added an option to only lazy load text widgets.

I hook observers before every sidebar and clear them after each sidebar.
I used undocumented action hooks, but you can find them in the wordpress source code (widgets.php classes)

Added the ability to lazy load twitter timelines.

Tested all the functionality on a live site - it works perfectly in my tests.

Greetings from Iceland ;)

Sigurður Guðbrandsson added 4 commits November 7, 2014 16:03
This modification adds the ability to lazy load all items in the sidebar (not only the text_widget).
Optionally, you can select "text widget" if you don't want to use an observer.

Also added twitter timeline lazy loading.
Added the ability to lazy load the whole sidebar, as opposed to only the text widgets.
You can also select the option to lazy load only text widgets.

Modified the function 'filter' to check for lazy loading the twitter timeline.

Added the function '_filter_twitter_timeline' to filter the twitter timeline.
Yes, the regex is SUPPOSED to be safe .. but you never know about regex (esp since HTML is irregular)
Hmm .. maybe it would have been smart to allow both single quote and double quote .. as well as allow for more classes ... oh well.. next revision.

Changed the function '_get_options' to include the new 'filter_sidebar_widgets' (had to remove filter_text_widget) and 'lazy_load_twitter_timeline'

Added functions 'observe_sidebar' and 'stop_observing_sidebar_and_output_sidebar' to observe the sidebar html output.
The functions do not run on the admin side, only the template side.
The action hooks are not documented, but you can find them in widgets.php in the wordpress repository.
Added twitter timeline lazy loading javascript code.
This allows twitter timelines to be lazy loaded.
Used Google's Closure Compiler to compile the bj-lazy-load.js and jquery.sonar.js.
Used "simple" settings from the closure compiler.
http://closure-compiler.appspot.com/home
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant