Added sidebar widget lazy loading + twitter timeline lazy loading#5
Open
SGudbrandsson wants to merge 4 commits intoAngrycreative:masterfrom
Open
Added sidebar widget lazy loading + twitter timeline lazy loading#5SGudbrandsson wants to merge 4 commits intoAngrycreative:masterfrom
SGudbrandsson wants to merge 4 commits intoAngrycreative:masterfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ;)