-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
892 lines (350 loc) · 22.7 KB
/
index.html
File metadata and controls
892 lines (350 loc) · 22.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
<!DOCTYPE html>
<html class="theme-next gemini" lang="ko">
<head><meta name="generator" content="Hexo 3.9.0">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.2/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/main.css?v=7.0.1">
<link rel="apple-touch-icon" sizes="180x180" href="/images/logo/apple-icon-180x180.png?v=7.0.1">
<link rel="icon" type="image/png" sizes="32x32" href="/images/logo/favicon-32x32.png?v=7.0.1">
<link rel="icon" type="image/png" sizes="16x16" href="/images/logo/favicon-16x16.png?v=7.0.1">
<script id="hexo.configurations">
var NexT = window.NexT || {};
var CONFIG = {
root: '/',
scheme: 'Gemini',
version: '7.0.1',
sidebar: {"position":"left","display":"post","offset":12,"onmobile":false,"dimmer":false},
back2top: true,
back2top_sidebar: false,
fancybox: false,
fastclick: false,
lazyload: false,
tabs: true,
motion: {"enable":false,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
algolia: {
applicationID: '',
apiKey: '',
indexName: '',
hits: {"per_page":10},
labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
}
};
</script>
<meta name="description" content="WebRTC 소개WebRTC (Web Real-Time Communication)는 웹 브라우저 간에 플러그인 설치 없이 스트림과 데이터를 상호 통신할 수 있도록 설계된 JavaScript API이다. WebRTC는 구글이 오픈소스화한 프로젝트에서 기원하였으며, 그 뒤로 국제 인터넷 표준화 기구(IETF)가 프로토콜 표준화 작업을, W3C가 API 정의를">
<meta name="keywords" content="codeJS,webrtc">
<meta property="og:type" content="article">
<meta property="og:title" content="WebRTC (Web Real-Time Communication) 소개">
<meta property="og:url" content="http://yoursite.com/posts/WebRTC/index.html">
<meta property="og:site_name" content="Cross Code">
<meta property="og:description" content="WebRTC 소개WebRTC (Web Real-Time Communication)는 웹 브라우저 간에 플러그인 설치 없이 스트림과 데이터를 상호 통신할 수 있도록 설계된 JavaScript API이다. WebRTC는 구글이 오픈소스화한 프로젝트에서 기원하였으며, 그 뒤로 국제 인터넷 표준화 기구(IETF)가 프로토콜 표준화 작업을, W3C가 API 정의를">
<meta property="og:locale" content="ko">
<meta property="og:image" content="http://yoursite.com/posts/WebRTC/webrtc-browser.jpg">
<meta property="og:image" content="http://yoursite.com/posts/WebRTC/webrtc-connection-flow.jpg">
<meta property="og:image" content="http://yoursite.com/posts/WebRTC/webrtc-internals-tabs.png">
<meta property="og:image" content="https://avatars2.githubusercontent.com/u/1393664?s=200&v=4">
<meta property="og:updated_time" content="2020-08-05T01:15:32.460Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="WebRTC (Web Real-Time Communication) 소개">
<meta name="twitter:description" content="WebRTC 소개WebRTC (Web Real-Time Communication)는 웹 브라우저 간에 플러그인 설치 없이 스트림과 데이터를 상호 통신할 수 있도록 설계된 JavaScript API이다. WebRTC는 구글이 오픈소스화한 프로젝트에서 기원하였으며, 그 뒤로 국제 인터넷 표준화 기구(IETF)가 프로토콜 표준화 작업을, W3C가 API 정의를">
<meta name="twitter:image" content="http://yoursite.com/posts/WebRTC/webrtc-browser.jpg">
<link rel="canonical" href="http://yoursite.com/posts/WebRTC/">
<script id="page.configurations">
CONFIG.page = {
sidebar: "",
};
</script>
<title>WebRTC (Web Real-Time Communication) 소개 | Cross Code</title>
<noscript>
<style>
.use-motion .motion-element,
.use-motion .brand,
.use-motion .menu-item,
.sidebar-inner,
.use-motion .post-block,
.use-motion .pagination,
.use-motion .comments,
.use-motion .post-header,
.use-motion .post-body,
.use-motion .collection-title { opacity: initial; }
.use-motion .logo,
.use-motion .site-title,
.use-motion .site-subtitle {
opacity: initial;
top: initial;
}
.use-motion .logo-line-before i { left: initial; }
.use-motion .logo-line-after i { right: initial; }
</style>
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage" lang="ko">
<div class="container sidebar-position-left page-post-detail">
<div class="headband"></div>
<header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-wrapper">
<div class="site-meta">
<div class="custom-logo-site-title">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">Cross Code</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
<p class="site-subtitle">기술 블로그</p>
</div>
<div class="site-nav-toggle">
<button aria-label="Toggle navigation bar">
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home">
<a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>홈</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>아카이브<span class="badge">10</span></a>
</li>
</ul>
</nav>
</div>
</header>
<main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
<div id="posts" class="posts-expand">
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/posts/WebRTC/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="cross-code">
<meta itemprop="description" content="프론트엔드 개발을 좋아하는 사람들의 공동 블로그">
<meta itemprop="image" content="/images/logo/favicon-96x96.png">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Cross Code">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">WebRTC (Web Real-Time Communication) 소개
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">작성일</span>
<time title="Post created: 2019-07-03 23:11:31" itemprop="dateCreated datePublished" datetime="2019-07-03T23:11:31+09:00">2019-07-03</time>
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">Edited on</span>
<time title="Updated at: 2020-08-05 10:15:32" itemprop="dateModified" datetime="2020-08-05T10:15:32+09:00">2020-08-05</time>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="WebRTC-소개"><a href="#WebRTC-소개" class="headerlink" title="WebRTC 소개"></a>WebRTC 소개</h2><p>WebRTC (Web Real-Time Communication)는 웹 브라우저 간에 플러그인 설치 없이 스트림과 데이터를 상호 통신할 수 있도록 설계된 JavaScript API이다.</p>
<p>WebRTC는 구글이 오픈소스화한 프로젝트에서 기원하였으며, 그 뒤로 국제 인터넷 표준화 기구(IETF)가 프로토콜 표준화 작업을, W3C가 API 정의를 진행하였으며, 음성 통화, 영상 통화, P2P 파일 공유 등으로 활용 될 수 있다.</p>
<h2 id="WebRTC-지원-브라우저"><a href="#WebRTC-지원-브라우저" class="headerlink" title="WebRTC 지원 브라우저"></a>WebRTC 지원 브라우저</h2><p>최신 버전의 주요 브라우저들이 지원을 하고있습니다.</p>
<p><img src="./webrtc-browser.jpg" alt="WebRTC 지원 브라우저"></p>
<p>하지만 경험상 Edge브라우저는 개발과정에 디버깅이 힘들고 타 브라우저에 비해 성능도 떨어집니다.<br>Edge 크로미움 버전이 추후 나온다니 좋은 성능을 보여주기를 기대합니다.<br>경험상 크롬에서 먼저 개발하고 어느정도 안정화가 되면 브라우저를 확장해 나가는것을 추천합니다. </p>
<h2 id="WebRTC-주요-API"><a href="#WebRTC-주요-API" class="headerlink" title="WebRTC 주요 API"></a>WebRTC 주요 API</h2><ul>
<li><p>GetUserMedia<br>사용자의 카메라와 마이크 접근을 담당</p>
</li>
<li><p>GetDisplayMedia<br>화면공유를 위한 접근을 담당</p>
</li>
<li><p>RTCPeerConnection<br>Peer간의 연결을 위한 인스턴스를 생성하고, 연결 후 스트림 전송에 사용 (생성시 STUN 서버 요청)</p>
</li>
<li><p>RTCDataChannel<br>Peer간의 Data를 주고 받을 수 있는 Tunnel API (WebSocket과 유사하지만, P2P라 속도가 보다 빠름)</p>
</li>
</ul>
<h2 id="WebRTC-P2P기반-NAT-및-방화벽-통과-기법"><a href="#WebRTC-P2P기반-NAT-및-방화벽-통과-기법" class="headerlink" title="WebRTC P2P기반 NAT 및 방화벽 통과 기법"></a>WebRTC P2P기반 NAT 및 방화벽 통과 기법</h2><ul>
<li><p>STUN (Session Traversal Utilities for NAT) 서버<br>사내망 환경에 NAT를 통해 공인IP, Port를 알아내는 역할을 함</p>
</li>
<li><p>TURN (Traversal Using Relays around NAT) 서버<br>P2P 연결이 안되는 환경일때 트래픽을 중계하는데 사용함</p>
</li>
<li><p>ICE (Interactive Connectivity Establishment)<br>P2P 간 다이렉트로 통신을 위해 STUN, TURN 등의 기술을 종합 활용하여 라우팅 경로를 찾아내는 기술로 UDP hole punching (P2P간 공인IP가 아니더라도 최대한 연결 가능하도록 하는 기법)을 지원.</p>
</li>
</ul>
<h2 id="WebRTC-P2P-연결-절차"><a href="#WebRTC-P2P-연결-절차" class="headerlink" title="WebRTC P2P 연결 절차"></a>WebRTC P2P 연결 절차</h2><p><img src="./webrtc-connection-flow.jpg" alt="WebRTC Connection Flow">위 과정은 아래의 webrtc-internals 화면을 열어서 함께 보는것이 이해하는데 도움이 된다.</p>
<h2 id="WebRTC-Connection-Step-확인"><a href="#WebRTC-Connection-Step-확인" class="headerlink" title="WebRTC Connection Step 확인"></a>WebRTC Connection Step 확인</h2><p>크롬 주소창에 chrome://webrtc-internals 입력하면 WebRTC 연결 흐름과 상태를 볼 수 있다.<br>실제 개발을 할 때 개발자 콘솔창을 보는 시간 만큼 자주 보게되는 화면이다. </p>
<p><img src="./webrtc-internals-tabs.png" alt="WebRTC 디버깅"> </p>
<h2 id="WebRTC-활용한-서비스"><a href="#WebRTC-활용한-서비스" class="headerlink" title="WebRTC 활용한 서비스"></a>WebRTC 활용한 서비스</h2><ul>
<li>화상회의<ul>
<li><a href="https://remotemeeting.com" target="_blank" rel="noopener">https://remotemeeting.com</a></li>
<li><a href="https://appear.in" target="_blank" rel="noopener">https://appear.in</a></li>
<li><a href="https://jitsi.org" target="_blank" rel="noopener">https://jitsi.org</a></li>
<li><a href="https://free.gotomeeting.com" target="_blank" rel="noopener">https://free.gotomeeting.com</a></li>
</ul>
</li>
<li>메신저 기반 <ul>
<li><a href="https://hangouts.google.com" target="_blank" rel="noopener">https://hangouts.google.com</a></li>
<li><a href="https://sylaps.com" target="_blank" rel="noopener">https://sylaps.com</a></li>
</ul>
</li>
<li>교육<ul>
<li><a href="https://tutoring.co.kr" target="_blank" rel="noopener">https://tutoring.co.kr</a></li>
</ul>
</li>
<li>소셜<ul>
<li><a href="https://www.azarlive.com" target="_blank" rel="noopener">https://www.azarlive.com</a></li>
</ul>
</li>
</ul>
<h2 id="참고"><a href="#참고" class="headerlink" title="참고"></a>참고</h2><ul>
<li><a href="https://webrtclab.herokuapp.com" target="_blank" rel="noopener">WebRTC 연구실</a></li>
<li><a href="https://webrtc.github.io/samples" target="_blank" rel="noopener">WebRTC Samples</a></li>
<li><a href="https://en.wikipedia.org/wiki/HTML5_video#Browser_support" target="_blank" rel="noopener">브라우저 비디오코덱 지원 현황</a></li>
</ul>
<h2 id="작성자"><a href="#작성자" class="headerlink" title="작성자"></a>작성자</h2><p><img src="https://avatars2.githubusercontent.com/u/1393664?s=200&v=4" width="100" align="left" style="margin-right: 10px"></p>
<p><strong>codeJS 🐘</strong><br><a href="https://github.com/dodortus" target="_blank" rel="noopener">https://github.com/dodortus</a><br><code>simple is best</code></p>
</div>
<footer class="post-footer">
<div class="post-tags">
<a href="/tags/codeJS/" rel="tag"># codeJS</a>
<a href="/tags/webrtc/" rel="tag"># webrtc</a>
</div>
<div class="post-nav">
<div class="post-nav-next post-nav-item">
<a href="/posts/바람직한-프로그래머-되기/" rel="next" title="바람직한 프로그래머 되기">
<i class="fa fa-chevron-left"></i> 바람직한 프로그래머 되기
</a>
</div>
<span class="post-nav-divider"></span>
<div class="post-nav-prev post-nav-item">
<a href="/posts/react-code-splitting/" rel="prev" title="React Code Splitting">
React Code Splitting <i class="fa fa-chevron-right"></i>
</a>
</div>
</div>
</footer>
</div>
</article>
</div>
</div>
<div class="comments" id="comments">
<div id="disqus_thread">
<noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
</div>
</div>
</div>
<div class="sidebar-toggle">
<div class="sidebar-toggle-line-wrap">
<span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
<span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
</div>
</div>
<aside id="sidebar" class="sidebar">
<div class="sidebar-inner">
<ul class="sidebar-nav motion-element">
<li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
목차
</li>
<li class="sidebar-nav-overview" data-target="site-overview-wrap">
흝어보기
</li>
</ul>
<div class="site-overview-wrap sidebar-panel">
<div class="site-overview">
<div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
<img class="site-author-image" itemprop="image" src="/images/logo/favicon-96x96.png" alt="cross-code">
<p class="site-author-name" itemprop="name">cross-code</p>
<div class="site-description motion-element" itemprop="description">프론트엔드 개발을 좋아하는 사람들의 공동 블로그</div>
</div>
<nav class="site-state motion-element">
<div class="site-state-item site-state-posts">
<a href="/archives/">
<span class="site-state-item-count">10</span>
<span class="site-state-item-name">포스트</span>
</a>
</div>
<div class="site-state-item site-state-tags">
<span class="site-state-item-count">15</span>
<span class="site-state-item-name">태그</span>
</div>
</nav>
</div>
</div>
<!--noindex-->
<div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
<div class="post-toc">
<div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#WebRTC-소개"><span class="nav-text">WebRTC 소개</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#WebRTC-지원-브라우저"><span class="nav-text">WebRTC 지원 브라우저</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#WebRTC-주요-API"><span class="nav-text">WebRTC 주요 API</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#WebRTC-P2P기반-NAT-및-방화벽-통과-기법"><span class="nav-text">WebRTC P2P기반 NAT 및 방화벽 통과 기법</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#WebRTC-P2P-연결-절차"><span class="nav-text">WebRTC P2P 연결 절차</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#WebRTC-Connection-Step-확인"><span class="nav-text">WebRTC Connection Step 확인</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#WebRTC-활용한-서비스"><span class="nav-text">WebRTC 활용한 서비스</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#참고"><span class="nav-text">참고</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#작성자"><span class="nav-text">작성자</span></a></li></ol></div>
</div>
</div>
<!--/noindex-->
</div>
</aside>
</div>
</main>
<footer id="footer" class="footer">
<div class="footer-inner">
<div class="copyright">© <span itemprop="copyrightYear">2020</span>
<span class="with-love" id="animate">
<i class="fa fa-heart"></i>
</span>
<span class="author" itemprop="copyrightHolder">Cross Code Members</span>
</div>
</div>
</footer>
<div class="back-to-top">
<i class="fa fa-arrow-up"></i>
<span id="scrollpercent"><span>0</span>%</span>
</div>
</div>
<script>
if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
window.Promise = null;
}
</script>
<script src="/lib/jquery/index.js?v=2.1.3"></script>
<script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
<script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
<script src="/js/src/utils.js?v=7.0.1"></script>
<script src="/js/src/motion.js?v=7.0.1"></script>
<script src="/js/src/affix.js?v=7.0.1"></script>
<script src="/js/src/schemes/pisces.js?v=7.0.1"></script>
<script src="/js/src/scrollspy.js?v=7.0.1"></script>
<script src="/js/src/post-details.js?v=7.0.1"></script>
<script src="/js/src/next-boot.js?v=7.0.1"></script>
<script>
var disqus_config = function() {
this.page.url = "http://yoursite.com/posts/WebRTC/";
this.page.identifier = "posts/WebRTC/";
this.page.title = 'WebRTC (Web Real-Time Communication) 소개';
};
function loadComments() {
var d = document, s = d.createElement('script');
s.src = 'https://cross-code.disqus.com/embed.js';
s.setAttribute('data-timestamp', '' + +new Date());
(d.head || d.body).appendChild(s);
}
$(function() {
var offsetTop = $('#comments').offset().top - $(window).height();
if (offsetTop <= 0) {
// load directly when there's no a scrollbar
loadComments();
} else {
$(window).on('scroll.disqus_scroll', function() {
// offsetTop may changes because of manually resizing browser window or lazy loading images.
var offsetTop = $('#comments').offset().top - $(window).height();
var scrollTop = $(window).scrollTop();
// pre-load comments a bit? (margin or anything else)
if (offsetTop - scrollTop < 60) {
$(window).off('.disqus_scroll');
loadComments();
}
});
}
});
</script>
</body>
</html>