pub enum Loading {
Eager,
Lazy,
}Expand description
The loading attribute values for lazy-loading resources.
§Purpose
Controls when the browser should load images and iframes, enabling performance optimization through lazy loading of off-screen content.
§Usage Context
- Used with:
<img>,<iframe>elements - Performance: Lazy loading can significantly improve initial page load
- Default: Browser-dependent (typically
eager)
§Valid Values
Eager: Load the resource immediately, regardless of viewport positionLazy: Defer loading until the resource is near the viewport
§Example
use ironhtml_attributes::{AttributeValue, Loading};
let loading = Loading::Lazy;
assert_eq!(loading.to_attr_value(), "lazy");<img src="above-fold.jpg" loading="eager" alt="Loads immediately">
<img src="below-fold.jpg" loading="lazy" alt="Loads when near viewport">
<iframe src="widget.html" loading="lazy"></iframe>§WHATWG Specification
Variants§
Eager
Load the resource immediately, without deferring. Use for above-the-fold or critical content.
Lazy
Defer loading the resource until it is calculated to be near the viewport. Improves performance for below-the-fold content.
Trait Implementations§
Source§impl AttributeValue for Loading
impl AttributeValue for Loading
Source§fn to_attr_value(&self) -> Cow<'static, str>
fn to_attr_value(&self) -> Cow<'static, str>
Convert to the attribute value string.
impl Copy for Loading
impl Eq for Loading
impl StructuralPartialEq for Loading
Auto Trait Implementations§
impl Freeze for Loading
impl RefUnwindSafe for Loading
impl Send for Loading
impl Sync for Loading
impl Unpin for Loading
impl UnwindSafe for Loading
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more