IT |
ITmedia 総合記事一覧 |
[ITmedia News] 「青い鳥いないとかマジ無理……」な人向け、元のTwitterアイコンをiPhoneに復活させる方法 |
https://www.itmedia.co.jp/news/articles/2308/01/news162.html
|
iphone |
2023-08-01 18:17:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia ビジネスオンライン] 「ビッグモーター」オイル交換無料券、メルカリで出品相次ぐ |
https://www.itmedia.co.jp/business/articles/2308/01/news155.html
|
itmedia |
2023-08-01 18:08:00 |
TECH |
Techable(テッカブル) |
再生医療のバイオテクノロジーを応用し、国産牛の受精胚から多能性幹細胞を樹立。培養肉産業の発展へ |
https://techable.jp/archives/214463
|
hyperionfoodtech |
2023-08-01 09:00:53 |
IT |
情報システムリーダーのためのIT情報専門サイト IT Leaders |
Web高速化エンジン「WEXAL」に検証機能を追加、高速化できていない要素を検出して修復可能に | IT Leaders |
https://it.impress.co.jp/articles/-/25175
|
Web高速化エンジン「WEXAL」に検証機能を追加、高速化できていない要素を検出して修復可能にITLeadersプライム・ストラテジーは年月日、Webシステム高速化エンジン「WEXALPageSpeedTechnology」以下、WEXALの新機能として、WEXAL適用前とWEXAL適用後におけるWebページの整合性を検証する機能「インスペクター」を発表した。 |
2023-08-01 18:46:00 |
AWS |
AWS News Blog |
Now Open – AWS Israel (Tel Aviv ) Region |
https://aws.amazon.com/blogs/aws/now-open-aws-israel-tel-aviv-region/
|
Now Open AWS Israel Tel Aviv RegionIn June Jeff Barr announced the upcoming AWS Israel Tel Aviv Region Today we re announcing the general availability of the AWS Israel Tel Aviv Region with three Availability Zones and the il central API name The new Tel Aviv Region gives customers an additional option for running their applications and serving users from data centers … |
2023-08-01 09:35:12 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
TypeScriptのパワフルなツール: Null合体演算子 (`??`) をマスターしよう! |
https://qiita.com/itinerant_programmer/items/25d0350a7146c2cbddfa
|
javascriptt |
2023-08-01 18:57:48 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
「Reactの新機能!Concurrent ModeとuseDeferredValueを詳しく解説」 |
https://qiita.com/itinerant_programmer/items/411a5691015e96b5e007
|
concurrentmode |
2023-08-01 18:22:52 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
Redshift Serverless その3 |
https://qiita.com/s-niim/items/5e348b27d4f44f316a07
|
redshiftserverless |
2023-08-01 18:49:19 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
Next.jsを使ってAWS Cognitoユーザープールにサインアップ・サインインリクエストしてみる【その②】 |
https://qiita.com/ttf1998seiya/items/d7a0614b89487b7d6b8c
|
awscognito |
2023-08-01 18:46:49 |
GCP |
gcpタグが付けられた新着投稿 - Qiita |
Cloud Functionsを実行時、The request was not authenticatedエラーの対策法 |
https://qiita.com/owenc4a4/items/2edea616a65d70446388
|
cloudfunctions |
2023-08-01 18:39:54 |
技術ブログ |
Developers.IO |
AWS 事業本部 オペレーション部に Join しましたヒラネ(平根)です。 |
https://dev.classmethod.jp/articles/hirane-joined-classmethod/
|
class |
2023-08-01 09:48:27 |
海外TECH |
DEV Community |
Lazy loading images upon intersection in Angular |
https://dev.to/ayyash/lazy-loading-images-upon-intersection-in-angular-1p2m
|
Lazy loading images upon intersection in AngularImages are content whether allowed on the server or not They are usually controlled by host servers or off domain data stores Today we want to find a solution to multiple problems we usually face in small to medium size apps right after they start picking up the pace and become harder to manage The plan is to use browser supported mechanism if possible handle large and slow images have a fallback for broken images serve something for SSR search bots mainly Find the code on the same StackBlitz project We want to end up with something like this lt div class main bg crLazy assets images largeimage jpg options threshold gt some content lt div gt lt img crLazy images frontimage jpg src images blurredout jpg options threshold gt Following the advice for best performance and best user experience the images that need to be lazy loaded are usually those below the fold Yet we will have images at the top like hero backgrounds that need to be delayed HTML native attributesFirst let s get this one out of the way The newly introduced attribute for images loading lazy should take care of a whole lot of issues natively It is good it starts downloading images a good mile before intersection and it requests the image once Above the fold it loads immediately The images are their own http request and we still want to delay partially not to pinch away from anything else that matters the image matters but not as much as the SPA framework We could use decoding async attribute to help with that If JavaScript is disabled the browser automatically downloads all images with http request This means search bots will have access to the images We ll talk about what we can do with it later SetupThe barebone of the directive is the following Directive selector crLazy standalone true export class LazyDirective implements AfterViewInit Input crLazy string constructor private el ElementRef private renderer Renderer private lazyLoad entry IntersectionObserverEntry observer IntersectionObserver when intersecting if entry isIntersecting implement this then disconnect observer disconnect ngAfterViewInit if this platform isBrowser we ll have to do something for the server sometimes return const io new IntersectionObserver entries observer gt this lazyLoad entries observer threshold io observe this el nativeElement We will also have a couple of elements to test with here is the minimum HTML and CSS for this purpose lt div class bg image main bg crLazy cosmeticImage gt lt h gt Text over image lt h gt lt div gt lt picture class card figure gt lt img alt toyota src lowresImage crLazy serverImage gt lt picture gt lt style gt The bare minimum for background images bg image background no repeat center center background size cover main bg starts with background color or low res image main bg background color ddd we can also add a low res image by default display flex align items center justify content center example of card with known width card figure width vw display block card figure img width lt style gt Set attribute on intersectionThe first solution that comes to mind is to change the attribute when intersection occurs If the element is an IMG we change the src otherwise we change the background image in styles attribute After changing the image we do not wish to observe the element So we unobserve Or disconnect We will use the main property to be the image s new source We could start with a single observer per whole window but then we will run into a wall when threshold is needed So we ll skip and make it an observer per directive So it s safe to disconnect lazy loadif entry isIntersecting if IMG change src if entry target tagName IMG this renderer setAttribute this el nativeElement src src else change background image add the style this renderer setAttribute this el nativeElement style background image url src disconnect or unobserve observer unobserve entry target The initial value can be set directly in HTML it is the blurry low resolution image probably just a default sitting in assets folder and when intersection occurs it will be replaced For best results we need to establish a good starting point for the element so that it does not change size abruptly That can be done in css away from the directive It depends on your project and the context there is no silver bullet Knowing exactly the width and height or even aspect ratio is wishful thinking none of the CSS tricks in the wild will help you in a dynamic app But you can make educated guesses according to context We are using Angular Renderer API to manipulate the DOM to stick to their recommendation on the subject Lazy loading versus loading on loadI wanted to test slow loading images that was not easy so I just kept clearing the cache and hard reloading to get the new image every time In the example above the first side effect is that when the image starts downloading it removes the existing source and replaces it with void If the image is too large or the origin is too slow it would look awful One way to overcome this is to download the image on the side then replace the attribute when loaded if entry isIntersecting load the image on the side const img new Image img addEventListener load gt replace and disconnect start downloading img src this crLazy The immediate side effect of this approach is duplicate loading of the image The second time however the browser already saved a cached version I have tried multiple configurations of removing cache disabling cache in developer tools loading random images at the bottom of the page or on slow connection in Chrome and in Firefox my only conclusion and it was hard to draw one was thatBrowsers are pretty good at caching images I would not worry about images loading twice the second one is always the cached one Let s move on to other things Catch error loading imagesSince we have used the onLoad event we can also use the onError event An error occurs when the image simply fails to load times out or s on us That happens more often than I d like to admit What we need is a fallback image Let s also add a threshold option like we did before lazy directive new optionsinterface IOptions threshold number fallBack string null export class LazyDirective implements AfterViewInit Input options IOptions threshold fallBack null private lazyLoad when intersecting if entry isIntersecting create a dummy image const img new Image watch onload event img addEventListener load gt replace with img src and disconnect watch errors to load fallback if this options fallBack img addEventListener error gt replace with this options fallBack and disconnect set the source img src this crLazy A little bit of refactoring to bring out the image change logic on its own function and we are ready to go To test it in StackBlitz multiple URLs are included It works well lt picture class card figure gt lt img alt toyota src placeholderImage crLazy serverImage options fallBack fallBackImage gt lt picture gt Note the fallback image itself is not pre downloaded this is a tool it does not kill but if misused it might bite So the fallback image better be a local cached small version of a placeholder Setting defaultsSince we are at it if the server image set is null hey it happens we should set it to the default fallback immediately set defaultsngAfterViewInit allow null values be assuming fallBack if this crLazy amp amp this options fallBack this crLazy this options fallBack Another easy to add feature is to set the src attribute or initial background image to the fallback if it exists instead of doing that in CSS or in the IMG tag But I do not wish to lose the feature of having a fallback on error because I would like to show a loading image initially then on error replace with a placeholder Before we add this feature let s dive into a more serious subject server side rendering Server side renderingThe lower resolution of the image is a bit tricky to deal with because sometimes we want that image to be found by bots so you might want to make sure the image is loaded on SSR We cannot add the source directly and then remove it in JavaScript because that might not be fast enough The SSR version loads first then hydration kicks in You might argue if the image is fast enough it does not need to be lazy loaded in the first place True With that in mind placing the image src for server platform then removing it for client platform might just work But it s not what we are here for Taming the loading attributeBack out our loading lazy attribute The source image is the original image to be fed to SSR and search bots as well The enhancement we can add to this is error handling lazy loading with attribute loading onlyngAfterViewInit if this crLazy amp amp this options fallBack this crLazy this options fallBack this el nativeElement addEventListener error gt replace image with fallback setImage this optoins fallBack no intersection observer Unfortunately if the image is slow we cannot replace it with a default initial value and load in the background because that kind of voids the idea of the loading attribute The complete propertyI tried to replace the image on the browser platform if the image was not complete by the SSR run but I got inconsistent results so I gave it up We also have to observe intersections with this solution it made no sense to me so I am not going down this path experimental codengAfterViewInit if this platform isBrowser amp amp this el nativeElement tagName amp amp this el nativeElement complete replace with fallback setImage this options fallBack then add intersection observer Filter out bot user agentsSo back to the original problem how do we make the final image available for search bots We can only be explicit on the server platform as to which user agents get to see the original image Let s start with a method that returns true for a list of bots we think we want to target Here is a thorough list I found on the web funny enough I can t find twitter bot there can you check user agent for a possible botprivate isBot agent string boolean return bot googlebot crawler spider robot crawling facebook twitter bing linkedin duckduck i test agent Then we need to inject the REQUEST token that is provided by the ngExpressEngine on SSR bring in the REQUEST tokenimport REQUEST from nguniversal express engine tokens import Request from express inject in constructor Optional Inject REQUEST private request Request on initngAfterViewInit if on server check user agent if this isBrowser amp amp this request check if it s a bot if this isBot this request get user agent load image and return this setImage this crLazy then stop and return return other server uses don t need to see anything return With that the image is available for the bot Start with initial sourceNow that we got the server platform out of the way let s go back to setting a default through code Instead of assigning the image src or CSS background image we can rely on an optional feature to set it Let s add a new option initial If it exists we will immediately replace the image so this better be a small cacheable fast loading image new option for initial valueinterface IOptions threshold number fallBack string initial string ngAfterViewInit if this platform isBrowser amp amp this request return if this options initial this setImage this options initial Now we can use it like this in our templates this removes reliability on css setting the background image lt img alt toyota crLazy serverImage options fallBack fallBackImage initial loadingImage gt lt div class bg image main bg hm h crLazy cosmeticLargeImage options initial initialmage gt We can also now create a loading effect for the image Setting a null cssLet s take it up a notch Let s use a class that initially displays in background or when the image fails or when there is no image Side note Adding an initial style to an image is very challenging we cannot target before and after pseudo elements and the source must be set and not broken if we are to target the background Which quite nullifies the value of adding css For background images however it is very beneficial Say we have a hero background image at the top of the screen Consider the following css example of hero waiting for image hero background no repeat center center background size cover background color rgba background blend mode overlay color fff min height dvh display flex align items center justify content center image set by code Here is how the hero looks when image succeeds to load and when the image is nullSo let s fix that problem without resolving to a fall back image By adding a css then upon success removing it In with the new optioninterface IOptions threshold number fallBack string initial string nullCss string on init set nullCssngAfterViewInit if this options nullCss this renderer addClass this el nativeElement this options nullCss on success remove itprivate lazyLoad entry IntersectionObserverEntry observer IntersectionObserver img addEventListener load gt this setImage img src success remove extra css this renderer removeClass this el nativeElement this options nullCss disconnect observer disconnect We can make use that in HTML and css as following lt style gt hero null background color black lt style gt lt div class hero crLazy null options nullCss hero null gt A broken hero lt div gt Now if the image is too slow or does not load at all we can fall back to a different style ConclusionWe set out to create a directive that makes use of the IntersectionObserver API and created two directives thus far here are the takeaways Having a single observer on window level is a good idea but it does not allow us to fine tuning the threshold property The performance is not hurt dramatically if we have everything under control If the number of elements is expected to be too many probably a new parent directive should be created for all sub elements as it is described in this blog post on Bennadel com We created a directive to add and remove classes to the element and to the body on in view and out of view incidents for maximum control We learned that classList add fails classList add null doesn t that was interesting We added a lazy loading mechanism for images and took care of multiple scenarios initial images null classes waiting for large images to load first handling errors of image loads and falling back to defaults We also handled search bots for images A couple of loose ends and one more use of the intersectionObserver we ll look into it next week Inshallah Thank you for reading this far did you try it yourself Let me know how it went for you RESOURCES StackBlitz project IntersectionObserver API Performance IntersectionObserver API ElementRef Doc isBot user agents list |
2023-08-01 09:40:25 |
海外科学 |
NYT > Science |
How Grand Canyon National Park Works to Prevent Heat-Related Deaths and Injuries |
https://www.nytimes.com/2023/08/01/travel/grand-canyon-heat-search-rescue.html
|
How Grand Canyon National Park Works to Prevent Heat Related Deaths and InjuriesIn a summer of deadly heat for hikers in the Southwest rangers at Grand Canyon National Park use a pioneering approach of aggressive messaging and outreach to prevent disaster on the trails |
2023-08-01 09:00:40 |
ニュース |
BBC News - Home |
Bibby Stockholm: No timeframe for migrant barge arrivals |
https://www.bbc.co.uk/news/uk-politics-66371897?at_medium=RSS&at_campaign=KARANGA
|
bibby |
2023-08-01 09:45:25 |
ニュース |
BBC News - Home |
Cardi B: Why are fans throwing things on stage? |
https://www.bbc.co.uk/news/newsbeat-66085967?at_medium=RSS&at_campaign=KARANGA
|
cardi |
2023-08-01 09:00:56 |
ニュース |
BBC News - Home |
Why Pakistanis are taking the dangerous Libya route to Europe |
https://www.bbc.co.uk/news/world-asia-66362327?at_medium=RSS&at_campaign=KARANGA
|
libya |
2023-08-01 09:00:37 |
ニュース |
BBC News - Home |
Dart Charge: Issues continue for Dartford Crossing users |
https://www.bbc.co.uk/news/uk-england-kent-66370666?at_medium=RSS&at_campaign=KARANGA
|
payment |
2023-08-01 09:15:15 |
ニュース |
BBC News - Home |
BP profits drop after Russia-Ukraine war windfall fades |
https://www.bbc.co.uk/news/business-66369811?at_medium=RSS&at_campaign=KARANGA
|
energy |
2023-08-01 09:31:07 |
ニュース |
BBC News - Home |
Portugal 0-0 USA: World champions USA scrape into last 16 |
https://www.bbc.co.uk/sport/football/66369075?at_medium=RSS&at_campaign=KARANGA
|
Portugal USA World champions USA scrape into last Defending champions the USA miss out on finishing top of Group E thanks to an uninspiring draw against debutants Portugal at the Women s World Cup |
2023-08-01 09:41:52 |
ニュース |
BBC News - Home |
Vietnam 0-7 Netherlands: Dutch win Group E ahead of reigning champions United States |
https://www.bbc.co.uk/sport/football/66369501?at_medium=RSS&at_campaign=KARANGA
|
dunedin |
2023-08-01 09:18:16 |
ニュース |
BBC News - Home |
2023 Women's World Cup permutations: Who needs what in Australia and New Zealand |
https://www.bbc.co.uk/sport/football/66334546?at_medium=RSS&at_campaign=KARANGA
|
Women x s World Cup permutations Who needs what in Australia and New ZealandThe group stages of the Fifa Women s World Cup are approaching the sharp end and there is still plenty to be decided Here s what each team needs in order to qualify |
2023-08-01 09:20:09 |
IT |
週刊アスキー |
吉野家と松屋の「紅生姜」ってどう違う? |
https://weekly.ascii.jp/elem/000/004/147/4147813/
|
違い |
2023-08-01 18:20:00 |
IT |
週刊アスキー |
グーグル DeepMind、ロボット向けAI「RT-2」開発 |
https://weekly.ascii.jp/elem/000/004/147/4147707/
|
deepmind |
2023-08-01 18:15:00 |
IT |
週刊アスキー |
ワンダーフェスティバル2023[夏]開催! 完璧で究極のアイドルが増加中! |
https://weekly.ascii.jp/elem/000/004/147/4147874/
|
世界最大 |
2023-08-01 18:15:00 |
IT |
週刊アスキー |
シャープ、新デザインのドライヤー3機種。大風量+プラズマクラスターでうるツヤに |
https://weekly.ascii.jp/elem/000/004/147/4147853/
|
速乾性 |
2023-08-01 18:30:00 |
コメント
コメントを投稿