WordPress / wp-lazy-loading

Feature plugin for testing and experimenting with the "loading" HTML attribute.
https://wordpress.org/plugins/wp-lazy-loading/
GNU General Public License v2.0
69 stars 21 forks source link

Add/abstract filtering of tags #9

Closed azaozz closed 4 years ago

azaozz commented 4 years ago

Makes the implementation a lot more flexible and easier to expand in the future.

See https://github.com/WordPress/wp-lazy-loading/pull/4.

azaozz commented 4 years ago

Looking at this again, code is good but wondering if this functionality should be added in the first place :)

It allows "searching" the content for any (opening) HTML tags, then runs a tag-specific filter on the found tags. General drawback is that it will only be used to find img for now and eventually for iframes.

It may be useful in the future if there's an attribute we'd want to auto-add similarly to "loading", or perhaps to remove an attribute or a class name as a "last resort" fix in some cases. It may also be useful for some plugins as there will be only one preg_replace_callback(), not several. But all of these cases are quite "theoretical" for now, perhaps best to add it when it's needed more.

felixarntz commented 4 years ago

@azaozz I think we can keep this simple for now and limited to img tags (see #3). As long as the public interface we introduce (filters) is flexible for the future, we should be good. In other words, I think we should keep the wp_lazy_loading_enabled contextual including a variable $tag_name, while for now this would only ever be img.

azaozz commented 4 years ago

I think we can keep this simple for now...

Yeah, thinking the same. Can add the extended support when it's "really needed" :)